# ********************************************************************
# * Date: 		17 August 2020
# * Authors: 		N. Karouzakis & K. Tzioumis
# * Paper title: 		Spillover costs of national security policies
# * Program's purpose: 	To produce Figure 4 - BSTS results
# ********************************************************************

library(CausalImpact)
library(zoo)

setwd("~/Desktop/ATR")

cor.figure4 <- read.csv("Figure_4_Data.csv")
View(cor.figure4)

attach(cor.figure4)

y <-subset(cor.figure4,select=c("Middle_East"))
x1<-subset(cor.figure4,select=c("Africa"))
x2<-subset(cor.figure4,select=c("Asia"))
x3<-subset(cor.figure4,select=c("Caribbean"))
x4<-subset(cor.figure4,select=c("Central_America"))
x5<-subset(cor.figure4,select=c("Eastern_Europe"))
x6<-subset(cor.figure4,select=c("Oceania"))
x7<-subset(cor.figure4,select=c("South_America"))
x8<-subset(cor.figure4,select=c("Western_Europe"))

time.points<-seq.Date(as.Date("2011-01-01"), by = 31, length.out = 102)

figure4data<-zoo(cbind(y,x1,x2,x3,x4,x5),time.points)

post.ban<-as.Date(c("2017-02-10", "2019-07-29"))
pre.ban <-as.Date(c("2011-01-01", "2017-01-10"))

arrival.impact<-CausalImpact(figure4data,pre.ban,post.ban)

plot(arrival.impact)

summary(arrival.impact)





